<?php

namespace app\api\controller;

use app\api\server\User as ServerUser;
use app\common\controller\Api;
use app\common\library\Wechat;
use app\common\model\Area;
use app\common\model\Banner;
use app\common\model\firm\Category;
use app\common\model\firm\Info;
use app\common\model\Province;
use app\common\model\User;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {

        // ServerUser::upgrade(User::get(17));

        $lunbo = Banner::all(['type' => 1]);
        $video = Banner::all(['type' => 2]);

        $this->success('请求成功', compact('lunbo', 'video'));
    }
    /**
     * @Author LK
     * @date: 2024-01-05 
     * @ApiTitle (未开通省)
     * @ApiMethod (GET)
     * @ApiMethod (POST)
     * @ApiParams (name="id", type="integer", required=true, sample="", description="ID")
     * @ApiParams (name="type", type="string", required=true, sample="", description="ID")
     * @ApiReturnParams (name="code", type="integer", required=true, description="")
     * @ApiReturn ({'code':1,'msg':'返回成功'})
     */
    public function open_province()
    {
        $area_ids = User::where('group_id', 5)->column('area_id');
        $list = Area::where('pid', 0)->whereNotIn('id', $area_ids)->field('id,name')->select();
        $this->success('', $list);
    }

    /**
     * @Author LK
     * @date: 2024-01-10 
     * @ApiTitle (企业分类)
     * @ApiMethod (GET)
     * @ApiReturnParams (name="code", type="integer", required=true, description="")
     * @ApiReturn ({'code':1,'msg':'返回成功'})
     */
    public function firm_category()
    {
        $lists = Category::all();
        $this->success('', $lists);
    }
    /**
     * @Author LK
     * @date: 2024-01-10 
     * @ApiTitle (企业)
     * @ApiMethod (GET)
     * @ApiParams (name="id", type="integer", required=true, sample="", description="ID")
     * @ApiReturnParams (name="code", type="integer", required=true, description="")
     * @ApiReturn ({'code':1,'msg':'返回成功'})
     */
    public function firm()
    {
        $params = request()->param();
        extract($params);
        $lists = Info::where('category_id', $id)->paginate();
        $this->success('', $lists);
    }
}
